import axios from '@/utils/api'

const News = () => {
    return axios.get("http://localhost:3000/api/blog")
}

// 删除
const delBlog = (id) => {
    return axios.post("http://localhost:3000/api/delBlog", { id })
}

// 修改
const updateBlog = (id, title, publishedAt, uptime,  p_1, p_2, url_1, url_2) => {
    return axios.post("http://localhost:3000/api/updateBlog", { id, title, publishedAt, uptime,  p_1, p_2, url_1, url_2 })
}

// 添加
const addBlog = (title, publishedAt, uptime,auname,  p_1, p_2, url_1, url_2) => {
    // console.log(username,password);
    return axios.post("http://localhost:3000/api/addBlog", { title, publishedAt, uptime, auname, p_1, p_2, url_1, url_2 })
}
// 筛选
const selectnews = (title) => {
    const query = { title };
    const filterQuery = Object.fromEntries(
        Object.entries(query).filter(([key, value]) => value)
    );
    return axios.post("http://localhost:3000/api/selectnews", { filterQuery })
}

 
// 浏览量
const view_num = () => {
    return axios.post("http://localhost:3000/api/addView_Num", { id })
}



export { News, delBlog, updateBlog, addBlog, selectnews, view_num }